package pyip.lib.javalearn.thread.join;

import pyip.lib.javalearn.Printer;

/**
 * @author yepeng
 * @date 2015年4月27日
 */
public class JoinDemo implements Runnable {

    @Override
    public void run() {
        Printer.out.println("sub thread start", 1);
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        Printer.out.println("sub thread exit", 1);
    }

    public static void main(String[] args) {
        Printer.out.println("main start", 0);

        Thread sub = new Thread(new JoinDemo());
        sub.start();
        try {
            sub.join(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        Printer.out.println("main exit", 0);
    }
}
